﻿'/* Copyright (c) 2009, Graeme Grant (graeme@live.com.au)
' * All rights reserved.
' *
' * Redistribution and use in source and binary forms, with or without
' * modification, are permitted provided that the following conditions are met:
' *
' *   * Redistributions of source code must retain the above copyright
' *     notice, this list of conditions and the following disclaimer.
' * 
' *   * Redistributions in binary form must reproduce the above copyright
' *     notice, this list of conditions and the following disclaimer in the
' *     documentation and/or other materials provided with the distribution.
' * 
' *   * The name Graeme Grant may not be used to endorse or promote products
' *     derived from this software without specific prior written permission.
' *
' * THIS SOFTWARE IS PROVIDED BY GRAEME GRANT ``AS IS'' AND ANY
' * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
' * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
' * DISCLAIMED. IN NO EVENT SHALL Dr. WPF BE LIABLE FOR ANY
' * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
' * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
' * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
' * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
' * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
' * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
' */

Public Class Response

    Private _data As String
    Friend Property Data() As String
        Get
            Return _data
        End Get
        Set(ByVal value As String)
            _data = value
        End Set
    End Property

    Private _status As Enums.response_codes
    Public Property Status() As Enums.response_codes
        Get
            Return _status
        End Get
        Friend Set(ByVal value As Enums.response_codes)
            _status = value
        End Set
    End Property

    Public ReadOnly Property User() As User
        Get
            Dim _user As New User(_data)
            Return _user
        End Get
    End Property

    Public ReadOnly Property Users() As Users(Of User)
        Get
            Return New Users(Of User)(_data)
        End Get
    End Property

    Public ReadOnly Property Shop() As Shop
        Get
            Dim _shop As New Shop(_data)
            Return _shop
        End Get
    End Property

    Public ReadOnly Property Shops() As Shops(Of Shop)
        Get
            Return New Shops(Of Shop)(_data)
        End Get
    End Property

    Public ReadOnly Property Listing() As Listing
        Get
            Dim _listing As New Listing(_data)
            Return _listing
        End Get
    End Property

    Public ReadOnly Property Listings() As Listings(Of Listing)
        Get
            Return New Listings(Of Listing)(_data)
        End Get
    End Property

    Public ReadOnly Property FeedBack() As Feedback
        Get
            Dim _FeedBack As New Feedback(_data)
            Return _FeedBack
        End Get
    End Property

    Public ReadOnly Property FeedBacks() As FeedBacks(Of Feedback)
        Get
            Return New FeedBacks(Of Feedback)(_data)
        End Get
    End Property

    Public ReadOnly Property Tags() As ArrayList
        Get
            Return CType(JSON.JsonDecode(_data), Hashtable)("results")
        End Get
    End Property

    Public ReadOnly Property GiftGuides() As GiftGuides(Of GiftGuide)
        Get
            Return New GiftGuides(Of GiftGuide)(_data)
        End Get
    End Property

    Public ReadOnly Property Methods() As Methods(Of Method)
        Get
            Return New Methods(Of Method)(_data)
        End Get
    End Property

    Public ReadOnly Property Ping() As String
        Get
            Return CType(JSON.JsonDecode(_data), Hashtable)("results")(0)
        End Get
    End Property

    Public ReadOnly Property ServerEpoch() As Date
        Get
            Return JSON.DecodeDateTime(CType(JSON.JsonDecode(_data), Hashtable)("results")(0))
        End Get
    End Property

End Class

